package com.jthinker.blog.dao.impl;

import com.jthinker.blog.bean.entity.Category;
import com.jthinker.blog.dao.CategoryDao;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

/**
 * User: Gang Chen
 * Date: 2015/7/5 14:31
 */
@Repository("categoryDao")
public class CategoryDaoImpl extends BaseDaoImpl<Category, Long> implements CategoryDao
{
    @Override
    public Long getIdBySlug(String slug)
    {
        String hql = "from Category where slug=:slug";

        Map<String, Object> params = new HashMap<String, Object>();
        params.put("slug", slug);

        Category category = super.read(hql, params);
        return category != null ? category.getId() : null;
    }
}
